package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.model.entity.TenantDeptEntity;
import com.uchiha.nova.core.model.vo.TenantDeptVO;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.util.SpringUtil;
import com.uchiha.nova.mainService.service.ITenantDeptService;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 组织机构表  包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class TenantDeptWrapper extends BaseEntityWrapper<TenantDeptEntity, TenantDeptVO>  {
  
  ITenantDeptService tenantDeptService = SpringUtil.getBean(ITenantDeptService.class);
  
	public static TenantDeptWrapper build() {
		return new TenantDeptWrapper();
 	}

	@Override
	public TenantDeptVO entityVO(TenantDeptEntity tenantDeptEntity) {
		TenantDeptVO tenantDeptVO = new TenantDeptVO();
		BeanUtil.copyProperties(tenantDeptEntity, tenantDeptVO);

		return tenantDeptVO;
	}
	public List<TenantDeptVO> listVO(List<TenantDeptEntity> list) {
		List<TenantDeptVO> collect = list.stream().map(item -> {
            TenantDeptVO tenantDeptVO = new TenantDeptVO();
		    BeanUtil.copyProperties(item, tenantDeptVO);			
			return tenantDeptVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<TenantDeptVO> pageVO(IPage<TenantDeptEntity> pages) {
		IPage<TenantDeptVO> page = pages.convert(item->{
            TenantDeptVO tenantDeptVO = new TenantDeptVO();
		    BeanUtil.copyProperties(item, tenantDeptVO);			
			return tenantDeptVO;
		});
		return page;
	}
}
